package com.thb.business.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.thb.business.model.Column;
import com.thb.business.service.IColumnService;
import com.thb.utils.ResponseTool;

@Controller
public class ColumnController  {
	
	Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private IColumnService columnService;
	
	@RequestMapping(value = "/column/list" , method = RequestMethod.POST)
	@ResponseBody
	public Object list(HttpServletRequest request){
		String json = request.getParameter("args");
		String sid = request.getParameter("sid");
		logger.info(String.format("args is: %s,sid is : %s", json,sid));
		Column para = JSON.parseObject(json,Column.class);
		List<Column> cList = columnService.findAllList(para);
		int count = columnService.countAllList(para);
		JSONObject page = new JSONObject();
		page.put("total", count);
		JSONObject r = new JSONObject();
		r.put("list", cList);
		r.put("page", page);
		return ResponseTool.returns(r);
	}

}
